﻿using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using FluentAvalonia.UI.Controls;
using iOSClub.Toolkit.WindowApp.Pages;
using iOSClub.Toolkit.WindowApp.ViewModels.Pages;

namespace iOSClub.Toolkit.WindowApp.MemberControls;

public partial class LoginControl : UserControl
{
    public LoginControl()
    {
        InitializeComponent();
    }

    private async void LoginClick(object? sender, RoutedEventArgs e)
    {
        var model = ViewServes.GetViewData<iOSManagerPageModel>(this);
        if(model == null)return;
        var result = await model.Login(NameBox.Text,IdBox.Text);
        if(string.IsNullOrEmpty(result))return;
        var td = new TaskDialog
        {
            Title = "西建大iOS Club工具包",
            Header = "社团官网登录",
            Content = result,
            IconSource = new SymbolIconSource { Symbol = Symbol.People },
            FooterVisibility = TaskDialogFooterVisibility.Never,
            XamlRoot = (Visual)VisualRoot!,
            Buttons =
            {
                TaskDialogButton.OKButton
            }
        };
        await td.ShowAsync(true);
    }
}